package com.x.erp.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.CarFavoriteDao;
import com.x.erp.model.Car;
import com.x.erp.model.CarFavorite;
import com.x.erp.rpc.CarFavoriteRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * 车辆收藏服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.CarCollectionRpcService", timeout = 60000)
public class CarFavoriteService extends BaseService implements CarFavoriteRpcService {

	@Autowired
	private CarFavoriteDao carFavoriteDao;// 车辆收藏DAO

	/**
	 * 查询车辆收藏列表
	 * 
	 * @param carFavorite
	 * @return
	 */
	@Override
	public List<Car> selectCarFavoriteList(CarFavorite carFavorite) {
		try {
			return carFavoriteDao.selectCarFavoriteList(carFavorite);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}
	/**
	 * 查询车辆收藏信息
	 * 
	 * @param carFavorite
	 * @return
	 */
	@Override
	public CarFavorite selectCarFavorite(CarFavorite carFavorite) {
		try {
			return carFavoriteDao.selectCarFavorite(carFavorite);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增车辆收藏信息
	 * 
	 * @param carCollection
	 * @return
	 */
	@Override
	public CarFavorite insertCarFavorite(CarFavorite carFavorite) {
		carFavorite.setFavoriteCreateTime(new Date());
		try {
			return this.insert(carFavorite);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 删除车辆收藏信息
	 * 
	 * @param carCollection
	 * @return
	 */
	@Override
	public int deleteCarFavorite(CarFavorite carFavorite) {
		return this.delete(carFavorite);
	}

}
